/**
 * Created by 1 on 2016/12/30.
 */
(function () {
    "use strict";
    var resourceTotalCount = 1;//资源总数量
    var resourceLoaded = 0;//当前已加载的资源数量
    var cacheMap = new Map();//用于存储资源的Map对象
    //检测资源是否加载完成
    var isAddLoaded = function () {
        resourceLoaded++;
        if (resourceLoaded === resourceTotalCount) {
            window.ResourceManager.onResourceLoaded();
        }
    };
    var init=function () {
        var image = new Image();
        image.src = "images/blocks.png";
        image.onload = function () {
            cacheMap.set("blocks", image);
            isAddLoaded();
        };
    };
    window.ResourceManager = {
        getResource:function (key) {
            return cacheMap.get(key);
        },
        _init:init
    };
})();